<template>
  <el-container class="list-container">
    <el-main class="main">
      <collapse-tab class="query">
        <el-form
          :inline="true"
          :model="queryCondition"
          label-width="80px"
          @keyup.enter.native="query"
        >
          <!--查询条件区 -->
          <el-form-item label="名称">
            <p-input v-model="queryCondition.name" class="form-item" />
          </el-form-item>
          <el-form-item label="编码">
            <p-input v-model="queryCondition.code" class="form-item" />
          </el-form-item>
          <el-form-item label="状态">
            <dictionary-select
              v-model="queryCondition.status"
              multiple
              :code="$constant.DICTIONARY_TYPE_CODES.STATUS"
            />
          </el-form-item>
          <el-form-item label="分类">
            <dictionary-select
              v-model="queryCondition.category"
              multiple
              :code="$constant.API_MESSAGE_TOPIC_CATEGORY"
            />
          </el-form-item>
          <el-form-item style="float:right;">
            <list-button-query :page-code="pageCode" />
          </el-form-item>
          <div class="clearfix" />
        </el-form>
      </collapse-tab>
      <el-card class="table">
        <div>
          <list-button-refresh :page-code="pageCode" />
          <list-button-add :page-code="pageCode" />
          <list-button-remove :page-code="pageCode" />
          <div style="clear:both;" />
        </div>
        <div style="margin-top:5px;">
          <div>
            <columns-controller v-model="columnList" :table-key="tableKey" />
          </div>
          <el-table
            v-loading="loading"
            :data="tableData"
            style="width: 100%"
            highlight-current-row
            border
            @sort-change="handleSortChange"
            @current-change="handleRowChange"
            @selection-change="handleSelectionChange"
            @row-dblclick="handleDoubleClickRow"
          >
            <el-table-column type="selection" width="55" />
            <el-table-column
              v-for="(item, index) in showCols"
              :key="index"
              :label="item.label"
              :prop="item.prop"
              :show-overflow-tooltip="item.showOverflowTooltip"
              :width="item.width"
              :formatter="item.formatFunc"
              :sortable="item.sortable"
            />
            <el-table-column fixed="right" label="操作" width="250">
              <template slot-scope="scope">
                <table-button-modify :id="scope.row.id" :page-code="pageCode" />
                <table-button-remove :id="scope.row.id" :page-code="pageCode" />
                <el-dropdown style="margin-left:10px;color:#1890ff">
                  <span class="el-dropdown-link">
                    更多
                    <i class="el-icon-arrow-down el-icon--right" />
                  </span>
                  <el-dropdown-menu slot="dropdown">
                    <el-dropdown-item>
                      <table-button-enable :id="scope.row.id" :page-code="pageCode" />
                    </el-dropdown-item>
                    <el-dropdown-item>
                      <table-button-disable :id="scope.row.id" :page-code="pageCode" />
                    </el-dropdown-item>
                  </el-dropdown-menu>
                </el-dropdown>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <list-pager
          :page-num="pageInfo.pageNum"
          :page-size="pageInfo.pageSize"
          :page-total="pageTotal"
        />
      </el-card>
      <detail ref="detail" @ok="handleDetailSave" />
    </el-main>
  </el-container>
</template>

<script>
import { listMixin } from '@/mixin/listMixin'
import Detail from './detail'

const MODULE_CODE = 'cip'
const ENTITY_TYPE = 'apiMessageTopic'
export default {
  name: ENTITY_TYPE,
  components: { Detail },
  mixins: [listMixin],
  data() {
    return {
      entityType: ENTITY_TYPE,
      moduleCode: MODULE_CODE,
      // eslint-disable-next-line no-eval
      api: eval('this.$api.' + MODULE_CODE + '.' + ENTITY_TYPE),
      pageCode: MODULE_CODE + ':' + ENTITY_TYPE + ':',
      queryCondition: {},
      columnList: [
        // prop label show 必须定义， width/showOverflowTooltip/formatFunc/sortable 需要的话定义
        { prop: 'name', label: '名称', show: true },
        { prop: 'code', label: '编码', show: true },
        { prop: 'handler', label: '处理器', show: true },
        { prop: 'categoryName', label: '分类', show: true },
        { prop: 'statusName', label: '状态', show: true },
        { prop: 'remark', label: '备注', show: true },
        { prop: 'orderNo', label: '排序号', show: true }
      ]
    }
  },
  methods: {

  }
}
</script>

<style lang="scss" scoped>
</style>
